<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  
  <title>5.x之RecyclerView的简单使用 | 不忘初心</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="转载: http:&#x2F;&#x2F;blog.csdn.net&#x2F;itachi85&#x2F;article&#x2F;details&#x2F;50036285    有了ListView、GridView为什么还需要RecyclerView这样的控件呢？整体上看RecyclerView架构，提供了一种插拔式的体验，高度的解耦，异常的灵活，更高的效率，通过设置它提供的不同LayoutManager，ItemDecoration , Ite">
<meta property="og:type" content="article">
<meta property="og:title" content="5.x之RecyclerView的简单使用">
<meta property="og:url" content="http://example.com/2017/07/11/RecyclerView/RecyclerView--5.x%E4%B9%8BRecyclerView%E7%9A%84%E7%AE%80%E5%8D%95%E4%BD%BF%E7%94%A8/index.html">
<meta property="og:site_name" content="不忘初心">
<meta property="og:description" content="转载: http:&#x2F;&#x2F;blog.csdn.net&#x2F;itachi85&#x2F;article&#x2F;details&#x2F;50036285    有了ListView、GridView为什么还需要RecyclerView这样的控件呢？整体上看RecyclerView架构，提供了一种插拔式的体验，高度的解耦，异常的灵活，更高的效率，通过设置它提供的不同LayoutManager，ItemDecoration , Ite">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="http://images.wxyass.com/20151202211106336.jpg">
<meta property="og:image" content="http://images.wxyass.com/20151202211122194.jpg">
<meta property="og:image" content="http://images.wxyass.com/20151202211136949.jpg">
<meta property="og:image" content="http://images.wxyass.com/20151202211157985.jpg">
<meta property="og:image" content="http://images.wxyass.com/20151202211224667.jpg">
<meta property="article:published_time" content="2017-07-11T05:26:37.000Z">
<meta property="article:modified_time" content="2018-07-15T07:43:36.000Z">
<meta property="article:author" content="wxyass">
<meta property="article:tag" content="RecyclerView">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://images.wxyass.com/20151202211106336.jpg">
  
    <link rel="alternate" href="/atom.xml" title="不忘初心" type="application/atom+xml">
  
  
    <link rel="shortcut icon" href="/favicon.png">
  
  
    
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/typeface-source-code-pro@0.0.71/index.min.css">

  
  
<link rel="stylesheet" href="/css/style.css">

  
    
<link rel="stylesheet" href="/fancybox/jquery.fancybox.min.css">

  
<meta name="generator" content="Hexo 5.4.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">不忘初心</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://example.com"></form>
      </div>
    </div>
  </div>
</header>

      <div class="outer">
        <section id="main"><article id="post-RecyclerView/RecyclerView--5.x之RecyclerView的简单使用" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  <div class="article-meta">
    <a href="/2017/07/11/RecyclerView/RecyclerView--5.x%E4%B9%8BRecyclerView%E7%9A%84%E7%AE%80%E5%8D%95%E4%BD%BF%E7%94%A8/" class="article-date">
  <time class="dt-published" datetime="2017-07-11T05:26:37.000Z" itemprop="datePublished">2017-07-11</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/RecyclerView/">RecyclerView</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="p-name article-title" itemprop="headline name">
      5.x之RecyclerView的简单使用
    </h1>
  

      </header>
    
    <div class="e-content article-entry" itemprop="articleBody">
      
        <blockquote>
<p>转载: <a target="_blank" rel="noopener" href="http://blog.csdn.net/itachi85/article/details/50036285">http://blog.csdn.net/itachi85/article/details/50036285</a>  </p>
</blockquote>
<p>有了ListView、GridView为什么还需要RecyclerView这样的控件呢？整体上看RecyclerView架构，提供了一种插拔式的体验，高度的解耦，异常的灵活，更高的效率，通过设置它提供的不同LayoutManager，ItemDecoration , ItemAnimator实现更加丰富多样效果。<br>但是RecyclerView也有缺点和让人头疼的地方：设置列表的分割线时需要自定义，另外列表的点击事件需要自己去实现   </p>
<span id="more"></span>



<h4 id="1-导入v7包"><a href="#1-导入v7包" class="headerlink" title="1.导入v7包"></a>1.导入v7包</h4><p>要想使用RecyclerView，我们首先要导入support-v7包，因为我用的是android studio所以我们需要在build.gradle加入如下代码用来自动导入support-v7包，记得配置完后重新Build一下工程。</p>



<pre class="prettyprint"><code class=" hljs rust">dependencies &#123;
    compile fileTree(include: <span class="hljs-string">'*.jar'</span>, <span class="hljs-keyword">dir</span>: <span class="hljs-string">'libs'</span>)
    compile <span class="hljs-string">'com.android.support:appcompat-v7:22.2.0'</span>
    compile <span class="hljs-string">'com.android.support:design:22.2.0'</span>
    compile <span class="hljs-string">'com.android.support:recyclerview-v7:22.1.0'</span>
&#125;</code></pre>

<h4 id="2-使用RecyclerView"><a href="#2-使用RecyclerView" class="headerlink" title="2. 使用RecyclerView"></a>2. 使用RecyclerView</h4><p>和ListView的写法大概一样：</p>
<pre class="prettyprint"><code class=" hljs cs"> RecyclerView mRecyclerView= (RecyclerView) <span class="hljs-keyword">this</span>.findViewById(R.id.id_recyclerview);
 <span class="hljs-comment">//设置布局管理器</span>
        mRecyclerView.setLayoutManager(<span class="hljs-keyword">new</span> LinearLayoutManager(<span class="hljs-keyword">this</span>));
        <span class="hljs-comment">// 设置item增加和删除时的动画</span>
        mRecyclerView.setItemAnimator(<span class="hljs-keyword">new</span> DefaultItemAnimator());
        mHomeAdaper=<span class="hljs-keyword">new</span> HomeAdapter(<span class="hljs-keyword">this</span>, mList);
        mRecyclerView.setAdapter(mHomeAdaper);
</code></pre>

<p>要比listview的设置要复杂一些，主要是需要自己去自定义分割线，设置动画和布局管理器等等。 <br>
布局文件activity_recycler_view.xml：</p>



<pre class="prettyprint"><code class=" hljs xml"><span class="hljs-pi">&lt;?xml version="1.0" encoding="utf-8"?&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">RelativeLayout</span> <span class="hljs-attribute">xmlns:android</span>=<span class="hljs-value">"http://schemas.android.com/apk/res/android"</span>
<span class="hljs-attribute">xmlns:tools</span>=<span class="hljs-value">"http://schemas.android.com/tools"</span>
<span class="hljs-attribute">android:layout_width</span>=<span class="hljs-value">"match_parent"</span>
<span class="hljs-attribute">android:layout_height</span>=<span class="hljs-value">"match_parent"</span> &gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-title">android.support.v7.widget.RecyclerView
</span>    <span class="hljs-attribute">android:id</span>=<span class="hljs-value">"@+id/id_recyclerview"</span>
    <span class="hljs-attribute">android:divider</span>=<span class="hljs-value">"#FFB900"</span>
    <span class="hljs-attribute">android:dividerHeight</span>=<span class="hljs-value">"1dp"</span>
    <span class="hljs-attribute">android:layout_width</span>=<span class="hljs-value">"match_parent"</span>
    <span class="hljs-attribute">android:layout_height</span>=<span class="hljs-value">"match_parent"</span>/&gt;</span>

<span class="hljs-tag">&lt;/<span class="hljs-title">RelativeLayout</span>&gt;</span></code></pre>

<p>让我们来看看变化最大的Adaper:</p>



<pre class="prettyprint"><code class=" hljs axapta"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">HomeAdapter</span> <span class="hljs-inheritance"><span class="hljs-keyword">extends</span></span> <span class="hljs-title">RecyclerView</span>.<span class="hljs-title">Adapter</span>&lt;<span class="hljs-title">HomeAdapter</span>.<span class="hljs-title">MyViewHolder</span>&gt;
&#123;</span>
    <span class="hljs-keyword">private</span> List&lt;String&gt; mList;
    <span class="hljs-keyword">private</span> Context mContext;;
    <span class="hljs-keyword">public</span> HomeAdapter(Context mContext,List&lt;String&gt;mList)&#123;
        <span class="hljs-keyword">this</span>.mContext=mContext;
        <span class="hljs-keyword">this</span>.mList=mList;
    &#125;

    <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> removeData(<span class="hljs-keyword">int</span> position) &#123;
        mList.remove(position);
        notifyItemRemoved(position);
    &#125;
    @Override
    <span class="hljs-keyword">public</span> MyViewHolder onCreateViewHolder(ViewGroup parent, <span class="hljs-keyword">int</span> viewType)
    &#123;
        MyViewHolder holder = <span class="hljs-keyword">new</span> MyViewHolder(LayoutInflater.from(
                mContext).inflate(R.layout.item_recycler, parent,
                <span class="hljs-keyword">false</span>));
        <span class="hljs-keyword">return</span> holder;
    &#125;

    @Override
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> onBindViewHolder(<span class="hljs-keyword">final</span> MyViewHolder holder, <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> position)
    &#123;
        holder.tv.setText(mList.get(position));
    &#125;

    @Override
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">int</span> getItemCount()
    &#123;
        <span class="hljs-keyword">return</span> mList.size();
    &#125;

    <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyViewHolder</span> <span class="hljs-inheritance"><span class="hljs-keyword">extends</span></span> <span class="hljs-title">RecyclerView</span>.<span class="hljs-title">ViewHolder</span>
    &#123;</span>

        TextView tv;
        <span class="hljs-keyword">public</span> MyViewHolder(View view)
        &#123;
            <span class="hljs-keyword">super</span>(view);
            tv = (TextView) view.findViewById(R.id.tv_item);
        &#125;
    &#125;
&#125;
</code></pre>

<p>最大的改进就是对ViewHolder进行了封装定义，不用自己去自定义了，另外Adaper继承RecyclerView.Adapter，在onCreateViewHolder加载条目布局，在onBindViewHolder中将视图与数据进行绑定。</p>

<p>布局文件item_recycler.xml：</p>



<pre class="prettyprint"><code class=" hljs xml"><span class="hljs-pi">&lt;?xml version="1.0" encoding="utf-8"?&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">FrameLayout</span> <span class="hljs-attribute">xmlns:android</span>=<span class="hljs-value">"http://schemas.android.com/apk/res/android"</span>
    <span class="hljs-attribute">android:layout_width</span>=<span class="hljs-value">"match_parent"</span>
    <span class="hljs-attribute">android:background</span>=<span class="hljs-value">"@android:color/white"</span>
    <span class="hljs-attribute">android:layout_height</span>=<span class="hljs-value">"wrap_content"</span>
    &gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-title">TextView
</span>        <span class="hljs-attribute">android:id</span>=<span class="hljs-value">"@+id/tv_item"</span>
        <span class="hljs-attribute">android:layout_width</span>=<span class="hljs-value">"match_parent"</span>
        <span class="hljs-attribute">android:layout_height</span>=<span class="hljs-value">"50dp"</span>
        <span class="hljs-attribute">android:gravity</span>=<span class="hljs-value">"center"</span>
        <span class="hljs-attribute">android:text</span>=<span class="hljs-value">"moon"</span> /&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">FrameLayout</span>&gt;</span></code></pre>

<p>来看看效果： </p>
<p><img src="http://images.wxyass.com/20151202211106336.jpg">  </p>
<p>没有分割线，难看的很，下面我们来讲一讲分割线。</p>
<h4 id="3-设置分割线-ItemDecoration"><a href="#3-设置分割线-ItemDecoration" class="headerlink" title="3. 设置分割线  ItemDecoration"></a>3. 设置分割线  ItemDecoration</h4><p>用mRecyclerView.addItemDecoration()来加入分割线，谷歌没有提供默认的分割线需要我们继承RecyclerView.ItemDecoration来自定义分割线：   </p>
<pre class="prettyprint"><code class=" hljs java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DividerItemDecoration</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">RecyclerView</span>.<span class="hljs-title">ItemDecoration</span> &#123;</span>

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>[] ATTRS = <span class="hljs-keyword">new</span> <span class="hljs-keyword">int</span>[]&#123;
            android.R.attr.listDivider
    &#125;;

    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL;

    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> VERTICAL_LIST = LinearLayoutManager.VERTICAL;

    <span class="hljs-keyword">private</span> Drawable mDivider;

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">int</span> mOrientation;

    <span class="hljs-keyword">public</span> <span class="hljs-title">DividerItemDecoration</span>(Context context, <span class="hljs-keyword">int</span> orientation) &#123;
        <span class="hljs-keyword">final</span> TypedArray a = context.obtainStyledAttributes(ATTRS);
        mDivider = a.getDrawable(<span class="hljs-number">0</span>);
        a.recycle();
        setOrientation(orientation);
    &#125;

    <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">setOrientation</span>(<span class="hljs-keyword">int</span> orientation) &#123;
        <span class="hljs-keyword">if</span> (orientation != HORIZONTAL_LIST &amp;&amp; orientation != VERTICAL_LIST) &#123;
            <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> IllegalArgumentException(<span class="hljs-string">"invalid orientation"</span>);
        &#125;
        mOrientation = orientation;
    &#125;

    <span class="hljs-annotation">@Override</span>
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onDraw</span>(Canvas c, RecyclerView parent) &#123;
        <span class="hljs-keyword">if</span> (mOrientation == VERTICAL_LIST) &#123;
            drawVertical(c, parent);
        &#125; <span class="hljs-keyword">else</span> &#123;
            drawHorizontal(c, parent);
        &#125;

    &#125;


    <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">drawVertical</span>(Canvas c, RecyclerView parent) &#123;
        <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> left = parent.getPaddingLeft();
        <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> right = parent.getWidth() - parent.getPaddingRight();

        <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> childCount = parent.getChildCount();
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; childCount; i++) &#123;
            <span class="hljs-keyword">final</span> View child = parent.getChildAt(i);
            android.support.v7.widget.RecyclerView v = <span class="hljs-keyword">new</span> android.support.v7.widget.RecyclerView(parent.getContext());
            <span class="hljs-keyword">final</span> RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                    .getLayoutParams();
            <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> top = child.getBottom() + params.bottomMargin;
            <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> bottom = top + mDivider.getIntrinsicHeight();
            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(c);
        &#125;
    &#125;

    <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">drawHorizontal</span>(Canvas c, RecyclerView parent) &#123;
        <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> top = parent.getPaddingTop();
        <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> bottom = parent.getHeight() - parent.getPaddingBottom();

        <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> childCount = parent.getChildCount();
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; childCount; i++) &#123;
            <span class="hljs-keyword">final</span> View child = parent.getChildAt(i);
            <span class="hljs-keyword">final</span> RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                    .getLayoutParams();
            <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> left = child.getRight() + params.rightMargin;
            <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> right = left + mDivider.getIntrinsicHeight();
            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(c);
        &#125;
    &#125;

    <span class="hljs-annotation">@Override</span>
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">getItemOffsets</span>(Rect outRect, <span class="hljs-keyword">int</span> itemPosition, RecyclerView parent) &#123;
        <span class="hljs-keyword">if</span> (mOrientation == VERTICAL_LIST) &#123;
            outRect.set(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, mDivider.getIntrinsicHeight());
        &#125; <span class="hljs-keyword">else</span> &#123;
            outRect.set(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, mDivider.getIntrinsicWidth(), <span class="hljs-number">0</span>);
        &#125;
    &#125;
&#125;
</code></pre>

<p>实现了自定义的分割线，我们只要在setAdapter之前加入如下代码便可加入分割线：</p>



<pre class="prettyprint"><code class=" hljs avrasm"> mRecyclerView<span class="hljs-preprocessor">.addItemDecoration</span>(new DividerItemDecoration(RecyclerViewActivity<span class="hljs-preprocessor">.this</span>, DividerItemDecoration<span class="hljs-preprocessor">.VERTICAL</span>_LIST))<span class="hljs-comment">;</span></code></pre>

<p><img src="http://images.wxyass.com/20151202211122194.jpg">  </p>
<h4 id="4-自定义点击事件"><a href="#4-自定义点击事件" class="headerlink" title="4. 自定义点击事件"></a>4. 自定义点击事件</h4><p> 列表中条目的点击事件需要我们自己来定义，这是一个不尽如人意的地方，但是自定义点击事件的话也并不是很难，在adaper中定义接口并提供回调：  </p>
<pre class="prettyprint"><code class=" hljs cs"> <span class="hljs-keyword">public</span> <span class="hljs-keyword">interface</span> OnItemClickListener
    &#123;
        <span class="hljs-keyword">void</span> onItemClick(View view, <span class="hljs-keyword">int</span> position);
        <span class="hljs-keyword">void</span> onItemLongClick(View view,<span class="hljs-keyword">int</span> position);

    &#125;

    <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">setOnItemClickListener</span>(OnItemClickListener mOnItemClickListener)
&#123;
    <span class="hljs-keyword">this</span>.mOnItemClickListener = mOnItemClickListener;
&#125;
</code></pre>

<p>接下来对item中的控件进行点击事件监听并回调给我们自定义的监听：</p>



<pre class="prettyprint"><code class=" hljs java"> <span class="hljs-annotation">@Override</span>
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onBindViewHolder</span>(<span class="hljs-keyword">final</span> MyViewHolder holder, <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> position)
    &#123;
        holder.tv.setText(mList.get(position));
        <span class="hljs-keyword">if</span> (mOnItemClickListener != <span class="hljs-keyword">null</span>)
        &#123;
            holder.tv.setOnClickListener(<span class="hljs-keyword">new</span> View.OnClickListener()
            &#123;
                <span class="hljs-annotation">@Override</span>
                <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onClick</span>(View v)
                &#123;
                    <span class="hljs-keyword">int</span> pos = holder.getLayoutPosition();
                    mOnItemClickListener.onItemClick(holder.tv,pos);
                &#125;
            &#125;);
            holder.tv.setOnLongClickListener(<span class="hljs-keyword">new</span> View.OnLongClickListener() &#123;
                <span class="hljs-annotation">@Override</span>
                <span class="hljs-keyword">public</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">onLongClick</span>(View view) &#123;
                    <span class="hljs-keyword">int</span> pos = holder.getLayoutPosition();
                    mOnItemClickListener.onItemLongClick(holder.tv,pos);
                    <span class="hljs-keyword">return</span> <span class="hljs-keyword">false</span>;
                &#125;
            &#125;);
        &#125;
    &#125;</code></pre>

<p>在Activity进行监听：</p>



<pre class="prettyprint"><code class=" hljs java"> mHomeAdaper.setOnItemClickListener(<span class="hljs-keyword">new</span> HomeAdapter.OnItemClickListener() &#123;
            <span class="hljs-annotation">@Override</span>
            <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onItemClick</span>(View view, <span class="hljs-keyword">int</span> position) &#123;
                Toast.makeText(RecyclerViewActivity.<span class="hljs-keyword">this</span>,<span class="hljs-string">"点击第"</span>+(position+<span class="hljs-number">1</span>)+<span class="hljs-string">"条"</span>,Toast.LENGTH_SHORT).show();
            &#125;

            <span class="hljs-annotation">@Override</span>
            <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onItemLongClick</span>(View view, <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> position) &#123;
                <span class="hljs-keyword">new</span> AlertDialog.Builder(RecyclerViewActivity.<span class="hljs-keyword">this</span>)
                        .setTitle(<span class="hljs-string">"确认删除嘛"</span>)
                        .setNegativeButton(<span class="hljs-string">"取消"</span>,<span class="hljs-keyword">null</span>)
                        .setPositiveButton(<span class="hljs-string">"确定"</span>, <span class="hljs-keyword">new</span> DialogInterface.OnClickListener() &#123;
                            <span class="hljs-annotation">@Override</span>
                            <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onClick</span>(DialogInterface dialogInterface, <span class="hljs-keyword">int</span> i) &#123;
                                mHomeAdaper.removeData(position);
                            &#125;
                        &#125;)
                        .show();
            &#125;
        &#125;);</code></pre>


<p>长按时会弹出对话框，删除时会有消失的动画：</p>
<p><img src="http://images.wxyass.com/20151202211136949.jpg">  </p>
<h4 id="5-实现GridView"><a href="#5-实现GridView" class="headerlink" title="5. 实现GridView"></a>5. 实现GridView</h4><p> 只需要自定义横向的分割线然后在代码中设置：</p>
<pre class="prettyprint"><code class=" hljs cs"> mRecyclerView.setLayoutManager(<span class="hljs-keyword">new</span> StaggeredGridLayoutManager(<span class="hljs-number">4</span>,
                StaggeredGridLayoutManager.VERTICAL));
                 mRecyclerView.addItemDecoration(<span class="hljs-keyword">new</span> DividerGridItemDecoration(<span class="hljs-keyword">this</span>));
</code></pre>


<p>具体的代码会在下面给的源码中可以看见，实现效果： </p>
<p><img src="http://images.wxyass.com/20151202211157985.jpg">  </p>
<h4 id="6-实现瀑布流"><a href="#6-实现瀑布流" class="headerlink" title="6. 实现瀑布流"></a>6. 实现瀑布流</h4><p> 虽然第三方实现的瀑布流已经很不错了，但是谷歌这次提供的RecyclerView支持瀑布流我们没有理由不去用，因为更稳定，效率更高，自定义能力更强。<br> 我们可以不用写<br>  mRecyclerView.addItemDecoration(new DividerGridItemDecoration(this));<br> 来设置分割线，可以在item布局文件中定义分割距离     android:layout_margin=”2dp”：   </p>
<pre class="prettyprint"><code class=" hljs xml"><span class="hljs-pi">&lt;?xml version="1.0" encoding="utf-8"?&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">FrameLayout</span> <span class="hljs-attribute">xmlns:android</span>=<span class="hljs-value">"http://schemas.android.com/apk/res/android"</span>
    <span class="hljs-attribute">android:layout_width</span>=<span class="hljs-value">"match_parent"</span>
    <span class="hljs-attribute">android:background</span>=<span class="hljs-value">"@android:color/white"</span>
    <span class="hljs-attribute">android:layout_height</span>=<span class="hljs-value">"wrap_content"</span>
    <span class="hljs-attribute">android:layout_margin</span>=<span class="hljs-value">"2dp"</span>
    &gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-title">TextView
</span>        <span class="hljs-attribute">android:id</span>=<span class="hljs-value">"@+id/tv_item"</span>
        <span class="hljs-attribute">android:layout_width</span>=<span class="hljs-value">"match_parent"</span>
        <span class="hljs-attribute">android:layout_height</span>=<span class="hljs-value">"50dp"</span>
        <span class="hljs-attribute">android:gravity</span>=<span class="hljs-value">"center"</span>
        <span class="hljs-attribute">android:text</span>=<span class="hljs-value">"moon"</span> /&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">FrameLayout</span>&gt;</span></code></pre>

<p>实现瀑布流很简单只要在adaper写一个随机的高度来控制每个item的高度就可以了，通常这个高度是由服务端返回的数据高度来控制的，在这里我们写一个随机的高度来控制每个item的高度：</p>



<pre class="prettyprint"><code class=" hljs matlab">mHeights = new ArrayList&lt;Integer&gt;();
        <span class="hljs-keyword">for</span> (int <span class="hljs-built_in">i</span> = <span class="hljs-number">0</span>; <span class="hljs-built_in">i</span> &lt; <span class="hljs-transposed_variable">mDatas.</span><span class="hljs-built_in">size</span>(); <span class="hljs-built_in">i</span>++)
        <span class="hljs-cell">&#123;
            mHeights.add( (int) (<span class="hljs-number">100</span> + Math.random() * <span class="hljs-number">300</span>));
        &#125;</span></code></pre>

<p>接着我们在adaper的onBindViewHolder来设置每个item的高度：</p>



<pre class="prettyprint"><code class=" hljs avrasm">LayoutParams lp = holder<span class="hljs-preprocessor">.tv</span><span class="hljs-preprocessor">.getLayoutParams</span>()<span class="hljs-comment">;</span>
        lp<span class="hljs-preprocessor">.height</span> = mHeights<span class="hljs-preprocessor">.get</span>(position)<span class="hljs-comment">;</span>
        holder<span class="hljs-preprocessor">.tv</span><span class="hljs-preprocessor">.setLayoutParams</span>(lp)<span class="hljs-comment">;</span></code></pre>

<p>具体的代码请看下面给的demo,来看看效果：</p>

<p><img src="http://images.wxyass.com/20151202211224667.jpg"></p>
<h4 id="7-源码说明"><a href="#7-源码说明" class="headerlink" title="7. 源码说明"></a>7. 源码说明</h4><p> 在RecyclerViewActivity的initView来配置你想要的效果：</p>
<pre class="prettyprint"><code class=" hljs cs"> <span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">initView</span>() &#123;
        mRecyclerView= (RecyclerView) <span class="hljs-keyword">this</span>.findViewById(R.id.id_recyclerview);
        <span class="hljs-comment">//设置GridView</span>
<span class="hljs-comment">//        setGridView();</span>
        <span class="hljs-comment">//设置ListView</span>
<span class="hljs-comment">//        setListView();</span>
         <span class="hljs-comment">//设置瀑布流</span>
        setWaterfallView();

    &#125;</code></pre>


<p><a target="_blank" rel="noopener" href="http://oss.wxyass.com/wxyass/demo/MyRecyclerView.zip">源码下载</a></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/2017/07/11/RecyclerView/RecyclerView--5.x%E4%B9%8BRecyclerView%E7%9A%84%E7%AE%80%E5%8D%95%E4%BD%BF%E7%94%A8/" data-id="ckvc340q5003e5dfybw28966y" data-title="5.x之RecyclerView的简单使用" class="article-share-link">Share</a>
      
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/RecyclerView/" rel="tag">RecyclerView</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2017/07/11/RecyclerView/RecyclerView--%E7%8E%A9%E8%BD%AC%E4%BB%BF%E6%8E%A2%E6%8E%A2%E5%8D%A1%E7%89%87%E5%BC%8F%E6%BB%91%E5%8A%A8%E6%95%88%E6%9E%9C/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          玩转仿探探卡片式滑动效果
        
      </div>
    </a>
  
  
    <a href="/2017/07/06/ListView/ListView--ListView%E4%B8%8A%E6%8B%89%E5%8A%A0%E8%BD%BD%E4%B8%8B%E6%8B%89%E5%88%B7%E6%96%B0/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">ListView上拉加载下拉刷新</div>
    </a>
  
</nav>

  
</article>


</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/Activity/">Activity</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Android-Studio%E4%BB%8B%E7%BB%8D/">Android Studio介绍</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Android%E5%9F%BA%E7%A1%80/">Android基础</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Android%E6%A8%A1%E6%9D%BF/">Android模板</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/BaseRecyclerViewAdapterHelper/">BaseRecyclerViewAdapterHelper</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Bug%E9%97%AE%E9%A2%98/">Bug问题</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Button/">Button</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/EditText/">EditText</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Fragment/">Fragment</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Gradle/">Gradle</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/ListView/">ListView</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/MD%E8%AF%AD%E6%B3%95/">MD语法</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/MyEclipse/">MyEclipse</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/OSS/">OSS</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/RecyclerView/">RecyclerView</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/SQL%E5%9F%BA%E7%A1%80/">SQL基础</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/UI%E6%8E%A7%E4%BB%B6/">UI控件</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/View/">View</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/ViewPager/">ViewPager</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/View%E7%AF%87/">View篇</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/as%E6%8A%A5%E9%94%99/">as报错</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/jar%E5%8C%85/">jar包</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/targetSdkVersion/">targetSdkVersion</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E4%B8%83%E7%89%9B%E4%BA%91/">七牛云</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E4%BA%8C%E7%BB%B4%E7%A0%81/">二维码</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%88%A0%E9%99%A4%E5%9B%BE%E7%89%87%E7%BC%93%E5%AD%98/">删除图片缓存</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%8D%87%E7%BA%A7%E6%8A%A5%E9%94%99/">升级报错</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/">博客搭建</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%8E%BB%E6%8E%89v7%E5%8C%85/">去掉v7包</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%9B%BE%E7%89%87%E5%A4%84%E7%90%86/">图片处理</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%A4%9A%E5%AA%92%E4%BD%93/">多媒体</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%AE%9A%E5%88%B6%E7%B1%BB/">定制类</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%B0%8F%E7%B1%B3%E6%89%8B%E6%9C%BA/">小米手机</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%B9%BF%E6%92%AD%E6%9C%BA%E5%88%B6/">广播机制</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%BE%AE%E5%8D%9A%E5%88%86%E4%BA%AB/">微博分享</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E6%89%93%E5%8C%85APK%E6%8A%A5%E9%94%99/">打包APK报错</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E6%8C%81%E4%B9%85%E5%8C%96%E5%AD%98%E5%82%A8/">持久化存储</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E6%97%B6%E9%97%B4%E9%80%89%E6%8B%A9DatePicker/">时间选择DatePicker</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E6%9C%8D%E5%8A%A1/">服务</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E6%9D%83%E9%99%90/">权限</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E6%9E%84%E5%BB%BA%E5%9F%BA%E7%B1%BB/">构建基类</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E6%B5%8B%E8%AF%95/">测试</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%9B%91%E5%90%AC%E9%94%81%E5%B1%8F/">监听锁屏</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%B3%BB%E7%BB%9F%E9%A1%B5%E9%9D%A2%E8%B7%B3%E8%BD%AC/">系统页面跳转</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E8%89%BA%E6%9C%AF%E6%8E%A2%E7%B4%A2/">艺术探索</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E8%AF%BB%E5%8F%96txt/">读取txt</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E8%BE%93%E5%85%A5%E6%B3%95/">输入法</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E9%9F%B3%E4%B9%90%E6%92%AD%E6%94%BE%E5%99%A8/">音乐播放器</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E9%BB%91%E9%A9%AC%E5%8D%AB%E5%A3%AB/">黑马卫士</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/Activity/" rel="tag">Activity</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Android-Studio/" rel="tag">Android Studio</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Android-Studio%E4%BB%8B%E7%BB%8D/" rel="tag">Android Studio介绍</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Android%E5%9F%BA%E7%A1%80/" rel="tag">Android基础</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Android%E6%A8%A1%E6%9D%BF/" rel="tag">Android模板</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/BaseRecyclerViewAdapterHelper/" rel="tag">BaseRecyclerViewAdapterHelper</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Bug%E9%97%AE%E9%A2%98/" rel="tag">Bug问题</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Button/" rel="tag">Button</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/EditText/" rel="tag">EditText</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Fragment/" rel="tag">Fragment</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Gradle/" rel="tag">Gradle</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ListView/" rel="tag">ListView</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/MD%E8%AF%AD%E6%B3%95/" rel="tag">MD语法</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/MyEclipse/" rel="tag">MyEclipse</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/OSS/" rel="tag">OSS</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/RecyclerView/" rel="tag">RecyclerView</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/SQL%E5%9F%BA%E7%A1%80/" rel="tag">SQL基础</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/UI%E6%8E%A7%E4%BB%B6/" rel="tag">UI控件</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/View/" rel="tag">View</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ViewPager/" rel="tag">ViewPager</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/View%E7%AF%87/" rel="tag">View篇</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/as%E6%8A%A5%E9%94%99/" rel="tag">as报错</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/jar%E5%8C%85/" rel="tag">jar包</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/targetSdkVersion/" rel="tag">targetSdkVersion</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E4%B8%83%E7%89%9B%E4%BA%91/" rel="tag">七牛云</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%8D%87%E7%BA%A7%E6%8A%A5%E9%94%99/" rel="tag">升级报错</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/" rel="tag">博客搭建</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%9B%BE%E7%89%87%E5%A4%84%E7%90%86/" rel="tag">图片处理</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%A4%9A%E5%AA%92%E4%BD%93/" rel="tag">多媒体</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%B7%A5%E4%BD%9C%E9%97%AE%E9%A2%98/" rel="tag">工作问题</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%B9%BF%E6%92%AD%E6%9C%BA%E5%88%B6/" rel="tag">广播机制</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%BA%94%E7%94%A8%E8%AF%A6%E6%83%85/" rel="tag">应用详情</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E5%BE%AE%E5%8D%9A%E5%88%86%E4%BA%AB/" rel="tag">微博分享</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%8C%81%E4%B9%85%E5%8C%96%E5%AD%98%E5%82%A8/" rel="tag">持久化存储</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%9C%8D%E5%8A%A1/" rel="tag">服务</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%9D%83%E9%99%90/" rel="tag">权限</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%9E%84%E5%BB%BA%E5%9F%BA%E7%B1%BB/" rel="tag">构建基类</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E7%94%9F%E6%B4%BB/" rel="tag">生活</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E7%BB%83%E6%89%8B/" rel="tag">练手</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%89%BA%E6%9C%AF%E6%8E%A2%E7%B4%A2/" rel="tag">艺术探索</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%BE%93%E5%85%A5%E6%B3%95/" rel="tag">输入法</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E9%AB%98%E7%BA%A7%E6%8A%80%E5%B7%A7/" rel="tag">高级技巧</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/Activity/" style="font-size: 12.5px;">Activity</a> <a href="/tags/Android-Studio/" style="font-size: 10px;">Android Studio</a> <a href="/tags/Android-Studio%E4%BB%8B%E7%BB%8D/" style="font-size: 12.5px;">Android Studio介绍</a> <a href="/tags/Android%E5%9F%BA%E7%A1%80/" style="font-size: 20px;">Android基础</a> <a href="/tags/Android%E6%A8%A1%E6%9D%BF/" style="font-size: 10px;">Android模板</a> <a href="/tags/BaseRecyclerViewAdapterHelper/" style="font-size: 10px;">BaseRecyclerViewAdapterHelper</a> <a href="/tags/Bug%E9%97%AE%E9%A2%98/" style="font-size: 10px;">Bug问题</a> <a href="/tags/Button/" style="font-size: 10px;">Button</a> <a href="/tags/EditText/" style="font-size: 10px;">EditText</a> <a href="/tags/Fragment/" style="font-size: 18.75px;">Fragment</a> <a href="/tags/Gradle/" style="font-size: 10px;">Gradle</a> <a href="/tags/ListView/" style="font-size: 17.5px;">ListView</a> <a href="/tags/MD%E8%AF%AD%E6%B3%95/" style="font-size: 11.25px;">MD语法</a> <a href="/tags/MyEclipse/" style="font-size: 13.75px;">MyEclipse</a> <a href="/tags/OSS/" style="font-size: 11.25px;">OSS</a> <a href="/tags/RecyclerView/" style="font-size: 12.5px;">RecyclerView</a> <a href="/tags/SQL%E5%9F%BA%E7%A1%80/" style="font-size: 10px;">SQL基础</a> <a href="/tags/UI%E6%8E%A7%E4%BB%B6/" style="font-size: 15px;">UI控件</a> <a href="/tags/View/" style="font-size: 10px;">View</a> <a href="/tags/ViewPager/" style="font-size: 10px;">ViewPager</a> <a href="/tags/View%E7%AF%87/" style="font-size: 10px;">View篇</a> <a href="/tags/as%E6%8A%A5%E9%94%99/" style="font-size: 10px;">as报错</a> <a href="/tags/jar%E5%8C%85/" style="font-size: 10px;">jar包</a> <a href="/tags/targetSdkVersion/" style="font-size: 10px;">targetSdkVersion</a> <a href="/tags/%E4%B8%83%E7%89%9B%E4%BA%91/" style="font-size: 10px;">七牛云</a> <a href="/tags/%E5%8D%87%E7%BA%A7%E6%8A%A5%E9%94%99/" style="font-size: 10px;">升级报错</a> <a href="/tags/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/" style="font-size: 12.5px;">博客搭建</a> <a href="/tags/%E5%9B%BE%E7%89%87%E5%A4%84%E7%90%86/" style="font-size: 15px;">图片处理</a> <a href="/tags/%E5%A4%9A%E5%AA%92%E4%BD%93/" style="font-size: 12.5px;">多媒体</a> <a href="/tags/%E5%B7%A5%E4%BD%9C%E9%97%AE%E9%A2%98/" style="font-size: 16.25px;">工作问题</a> <a href="/tags/%E5%B9%BF%E6%92%AD%E6%9C%BA%E5%88%B6/" style="font-size: 12.5px;">广播机制</a> <a href="/tags/%E5%BA%94%E7%94%A8%E8%AF%A6%E6%83%85/" style="font-size: 10px;">应用详情</a> <a href="/tags/%E5%BE%AE%E5%8D%9A%E5%88%86%E4%BA%AB/" style="font-size: 10px;">微博分享</a> <a href="/tags/%E6%8C%81%E4%B9%85%E5%8C%96%E5%AD%98%E5%82%A8/" style="font-size: 13.75px;">持久化存储</a> <a href="/tags/%E6%9C%8D%E5%8A%A1/" style="font-size: 12.5px;">服务</a> <a href="/tags/%E6%9D%83%E9%99%90/" style="font-size: 10px;">权限</a> <a href="/tags/%E6%9E%84%E5%BB%BA%E5%9F%BA%E7%B1%BB/" style="font-size: 10px;">构建基类</a> <a href="/tags/%E7%94%9F%E6%B4%BB/" style="font-size: 11.25px;">生活</a> <a href="/tags/%E7%BB%83%E6%89%8B/" style="font-size: 11.25px;">练手</a> <a href="/tags/%E8%89%BA%E6%9C%AF%E6%8E%A2%E7%B4%A2/" style="font-size: 10px;">艺术探索</a> <a href="/tags/%E8%BE%93%E5%85%A5%E6%B3%95/" style="font-size: 10px;">输入法</a> <a href="/tags/%E9%AB%98%E7%BA%A7%E6%8A%80%E5%B7%A7/" style="font-size: 11.25px;">高级技巧</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/11/">November 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/10/">October 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/09/">September 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/08/">August 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/07/">July 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/06/">June 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/04/">April 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/03/">March 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/02/">February 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/09/">September 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/10/">October 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/04/">April 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/01/">January 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/05/">May 2012</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2017/11/03/Android%20Studio/Github%E4%B8%8A%E6%8F%90%E4%BA%A4%E4%BB%A3%E7%A0%81/">Github上提交代码</a>
          </li>
        
          <li>
            <a href="/2017/10/31/RecyclerView/BaseRecyclerViewAdapterHelper%E5%BA%93%E7%9A%84%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95/">BaseRecyclerViewAdapterHelper库的基本使用方法</a>
          </li>
        
          <li>
            <a href="/2017/10/31/%E5%9B%BE%E7%89%87%E5%A4%84%E7%90%86/%E4%B8%83%E7%89%9B%E4%BA%91--%E4%B8%83%E7%89%9B%E4%BA%91%E5%BF%AB%E9%80%9F%E4%B8%8A%E4%BC%A0%E5%9B%BE%E7%89%87/">七牛云快速上传图片</a>
          </li>
        
          <li>
            <a href="/2017/10/31/Gradle/Gradle--Gradle%E6%B7%BB%E5%8A%A0%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%93%E6%8A%A5%E5%BC%82%E5%B8%B8/">Gradle添加第三方库报异常</a>
          </li>
        
          <li>
            <a href="/2017/10/26/Android%20Studio/%E8%A7%A3%E5%86%B3Android-Studio-Gradle-%E9%94%99%E8%AF%AF-%E7%BC%96%E7%A0%81GBK%E7%9A%84%E4%B8%8D%E5%8F%AF%E6%98%A0%E5%B0%84%E5%AD%97%E7%AC%A6/">解决Android Studio Gradle 错误 编码GBK的不可映射字符</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      
      &copy; 2021 wxyass<br>
      Powered by <a href="https://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>

    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    


<script src="/js/jquery-3.4.1.min.js"></script>



  
<script src="/fancybox/jquery.fancybox.min.js"></script>




<script src="/js/script.js"></script>





  </div>
</body>
</html>